#!/bin/bash
echo $CI_PROJECT_PATH_SLUG
#编译后将包拷贝至新建的/home/cifiadmin目录下，当前目录就是代码根目录。
#rm -rf package-lock.json

# npm config set registry https://registry.npm.taobao.org
# npm config set puppeteer_download_host=https://npm.taobao.org/mirrors

#npm config set registry https://registry.npm.taobao.org
#npm config set puppeteer_download_host=https://npm.taobao.org/mirrors

#注册为私有仓库地址
# npm install --registry=https://registry.npm.taobao.org ||  exit 1
# npm install --registry=http://10.129.32.7:4873/ ||  exit 1
npm install --registry=http://10.129.32.16:8081/repository/npm-groups/

echo "env: " $env

if [[ $env == 'dev' || $env == '' ]]; then
  npm run build || exit 1 
elif [[ $env == 'uat' ]]; then
  npm run build-uat || exit 1 
elif [[ $env == 'prod' ]]; then
  npm run build-prod || exit 1  
else
  echo  "Please enter env parameter 【dev|uat|prod】"
fi

mkdir -p publish/pcdist && \
cp -r dist/*  publish/pcdist/ || exit 1
echo "build successful"

